public class project {

    public boolean canConstruct(String s, int k) {
        int right=s.length();
        int[] arr=new int[26];
        for(int i=0;i<right;i++){
            arr[s.charAt(i)-'a']++;
        }
        int left=0;
        for(int i=0;i<26;i++){
            if(arr[i]%2==1){
                left++;
            }
        }
        left=Math.max(1,left);
        return left<=k&&k<=right;
    }













    public int countServers(int[][] grid) {
        int row=grid.length;
        int col=grid[0].length;
        int[] arr1=new int[row];
        int[] arr2=new int[col];
        int count=0;
        for(int i=0;i<grid.length;i++){
            for(int j=0;j<grid[0].length;j++){
                if(grid[i][j]==1){
                    arr1[i]++;
                    arr2[j]++;
                }
            }
        }
        for(int i=0;i<row;i++){
            for(int j=0;j<col;j++){
                if(grid[i][j]==1&&(arr1[i]>1||arr2[j]>1)){
                    count++;
                }
            }
        }
        return count;
    }


















    public int dominantIndex(int[] nums) {
        int max1=-1;
        int max2=-1;
        int index=-1;
        for(int i=0;i<nums.length;i++){
            if(nums[i]>max1){
                max2=max1;
                max1=nums[i];
                index=i;
            }else if(nums[i]>max2){
                max2=nums[i];
            }
        }
        return max1>=max2*2?index:-1;
    }
}
